StateMachine

open class StateMachine<S, T : Any> : IStateMachine<S, T>

A basic state machine that is not thread safe.

Constructors

Link copied to clipboard
fun <S, T : Any> StateMachine(initialState: S, vararg transitionRules: TransitionDef<S, out T>)
Link copied to clipboard
fun <S, T : Any> StateMachine(initialState: S, transitions: List<TransitionDef<S, out T>>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun registerCallback(transitionCallback: TransitionCallback<S, T>): Boolean

Register a callback for state transition updates.

Link copied to clipboard
open override fun transition(transition: T)

Transition the machine.

Link copied to clipboard
open override fun transitionsTo(targetState: S): Set<KClass<out T>>

Get the transition required to move to a given state.

Link copied to clipboard
fun unregisterCallback(transitionCallback: TransitionCallback<S, T>): Boolean

Unregister a callback from state transition updates.

Properties

Link copied to clipboard
override var state: S

Current state of the machine.

Link copied to clipboard
val transitionCallbacks: List<TransitionCallback<S, T>>

An immutable list of the currently registered callbacks.

Link copied to clipboard
open override val transitions: Set<KClass<out T>>

Transitions available to the current state.